﻿
window.SearchKey = null;

$.MGJ.WareHouse = [];
(function () {
    var _this = $.MGJ.WareHouse;
    $.extend($.MGJ.WareHouse, {
        EportExecl: function (ele) {
            
            $("input.AllClickChild:checked").each(function () {
                info.push($(this).attr('ID'));

            });
            if (info.length == 0) {
                $.L.msgError("请选择要导出的数据信息！");
                return
            }
            if (!$(ele).find('.no-result').hasClass('no-result')) {
                window.open(ACTION_URL("EportExecl", "Manager") + "?Key=" + info);
            }
            else {
                $.L.msgWarning('导出数据不能为空！')
            }
        }
    });
})(jQuery);

(function () {
    var _this = $.MGJ.WareHouse;
    $.extend($.MGJ.WareHouse, {
        Dialog_AEditWareObj: null,
        Dialog_AEditWare: function () {
            this.Dialog_AEditWareObj = $.L.dialog({
                url: ACTION_URL("AEditWare", "Manager"),
                title: "新增编辑仓库管理",
                width: 800,
                height: 'auto',
                buttons: {
                    "button_save": {
                        type: 'primary',
                        text: '保存',
                        click: function () {
                            var bootstrapValidator = $("#form_AddWareHouse").data('bootstrapValidator').validate();//触发全部验证
                            if (bootstrapValidator.isValid()) {
                                _this.Ajax_AddWareHouse();
                                $(".btn-primary").attr("disabled", true);
                            }
                            else {
                                $.L.msgError("请检查数据格式！");
                            };

                        }
                    },
                    "button_cancel": {
                        type: 'default',
                        text: '取消',
                        click: 'MODALMISS'
                    }
                }
            });

        },
        Dialog_EditWareObj: null,
        Dialog_EditWare: function (obj) {
            var id = $(obj).attr("WID");

            this.Dialog_EditWareObj = $.L.dialog({
                url: ACTION_URL("EditWare", "Manager") + "?id=" + id,
                title: "编辑",
                width: 800,
                height: "auto",
                buttons: {
                    "button_save": {
                        type: 'primary',
                        text: '保存',
                        click: function () {
                            var bootstrapValidator = $("#form_EditWareHouse").data('bootstrapValidator').validate();//触发全部验证
                            if (bootstrapValidator.isValid()) {
                                _this.Ajax_EditWareHouse(id);
                                $(".btn-primary").attr("disabled", true);
                            }
                            else {
                                $.L.msgError("请检查数据格式！");
                            };
                        }
                    },
                    "button_cancel": {
                        type: 'default',
                        text: '取消',
                        click: 'MODALMISS'
                    }
                }
            });
        }


    });
})(jQuery);
(function () {

    //查询仓库信息
    var _index = 1;
    var _this = $.MGJ.WareHouse;
    $.extend($.MGJ.WareHouse, {
        Ajax_GetWareHouseList: function (pageIndex) {
            _index = pageIndex;
            window.SearchKey = removeSpace($("#Wsearch").val());
            $.L.ajaxHandle({
                url: ACTION_URL("GetWareHouseList", "Manager"),
                data: {
                    Wsearch: window.SearchKey,
                    pageIndex: pageIndex,
                    pageSize: 10
                },
                success: function (response) {
                    $("#WareHouseTable").L_bindingDataList(response);
                }
            });
        },
        //新增仓库
        Ajax_AddWareHouse: function () {

            $.L.ajaxHandle({
                url: ACTION_URL("AddWareHouse", "Manager"),
                data: $("#form_AddWareHouse").serialize(),
                success: function (response) {
                    _this.Dialog_AEditWareObj.close();
                    if (response) {
                        $.L.msgSuccess("操作成功");
                        _this.Ajax_GetWareHouseList(1);
                    }
                }
            });
        },
        //修改
        Ajax_EditWareHouse: function (id) {

            $.L.ajaxHandle({
                url: ACTION_URL("EditWareHouse", "Manager") + "?id=" + id,
                data: $("#form_EditWareHouse").serialize(),
                success: function (response) {
                    _this.Dialog_EditWareObj.close();
                    if (response > 0) {
                        $.L.msgSuccess("操作成功！");
                        _this.Ajax_GetWareHouseList(1);
                    }

                }
            });
        },
        Ajax_DelWare: function (obj) {
            $.L.msgConfirm("确认删除该记录?", function () {
                var id = $(obj).attr("WID");
                $.L.ajaxHandle({
                    url: ACTION_URL("DelWare", "Manager") + "?id=" + id,
                    data: { id: id },
                    success: function (response) {
                        if (response > 0) {
                            $.L.msgSuccess("操作成功！");
                            _this.Ajax_GetWareHouseList(_index);

                        }
                    }
                });
            })

        }
    });
})(jQuery);

(function () {
    var _this = $.MGJ.WareHouse;
    $.extend($.MGJ.WareHouse, {

    });
})(jQuery);